/*
 * Copyright (C) 2015-2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#ifndef PLANET_WARS_2D_RT_CORE_MODEL_SHIP_POSITION_H
#define PLANET_WARS_2D_RT_CORE_MODEL_SHIP_POSITION_H


#include "PlanetWars2dRT-core/specific/model/ship_essential.h"


EXTERN_C_BEGIN


/* position current */

static inline
unsigned int
ship_get_top_left_position_current_x(const ship_t* a_ship)
{
  return (unsigned int) a_ship->position_current.x;
}

static inline
unsigned int
ship_get_top_left_position_current_y(const ship_t* a_ship)
{
  return (unsigned int) a_ship->position_current.y;
}

static inline
position_2d_uint
ship_get_top_left_position_current(const ship_t* a_ship)
{
  position_2d_uint position;
  position.x = ship_get_top_left_position_current_x(a_ship);
  position.y = ship_get_top_left_position_current_y(a_ship);
  return position;
}

static inline
unsigned int
ship_get_center_position_current_x(const ship_t* a_ship)
{
  return ship_get_top_left_position_current_x(a_ship) + a_ship->size.x / 2;
}

static inline
unsigned int
ship_get_center_position_current_y(const ship_t* a_ship)
{
  return ship_get_top_left_position_current_x(a_ship) + a_ship->size.y / 2;
}

static inline
position_2d_uint
ship_get_center_position_current(const ship_t* a_ship)
{
  position_2d_uint pos;
  pos.x = ship_get_center_position_current_x(a_ship);
  pos.y = ship_get_center_position_current_y(a_ship);
  return pos;
}

static inline
void
ship_set_top_left_position_current_x(ship_t* a_ship,
				     unsigned int new_position_x)
{
  a_ship->position_current.x = (float) new_position_x;
}

static inline
void
ship_set_top_left_position_current_y(ship_t* a_ship,
				     unsigned int new_position_y)
{
  a_ship->position_current.y = (float) new_position_y;
}

static inline
void
ship_set_top_left_position_current(ship_t* a_ship,
				   const position_2d_uint* new_position)
{
  ship_set_top_left_position_current_x(a_ship, new_position->x);
  ship_set_top_left_position_current_y(a_ship, new_position->y);
}


/* position to go */

static inline
unsigned int
ship_get_top_left_position_to_go_x(const ship_t* a_ship)
{
  return a_ship->position_to_go.x;
}

static inline
unsigned int
ship_get_top_left_position_to_go_y(const ship_t* a_ship)
{
  return a_ship->position_to_go.y;
}

static inline
position_2d_uint
ship_get_top_left_position_to_go(const ship_t* a_ship)
{
  return a_ship->position_to_go;
}

static inline
void
ship_set_top_left_position_to_go_x(ship_t* a_ship, unsigned int value)
{
  a_ship->position_to_go.x = value;
}

static inline
void
ship_set_top_left_position_to_go_y(ship_t* a_ship, unsigned int value)
{
  a_ship->position_to_go.y = value;
}

static inline
void
ship_set_top_left_position_to_go(ship_t* a_ship,
				 const position_2d_uint* new_position)
{
  ship_set_top_left_position_to_go_x(a_ship, new_position->x);
  ship_set_top_left_position_to_go_y(a_ship, new_position->y);
}


EXTERN_C_END


#endif
